package net.jalbum.filters.arty.effects;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.util.Map;
import se.datadosen.jalbum.JAFilter;

/**
 *
 * @author Sarah Schölzel 
 */
public class SnowdropFilter extends ArtySupport {

    public SnowdropFilter() {
    }

    @Override
    public String getName() {
        return "Snowdrop";
    }

    @Override
    public String getDescription() {
        return "photo gets a soft, glow effect";
    }

    @Override
    public BufferedImage filter(BufferedImage bi, Map map) {
        return filter(bi);
    }

    @Override
    public BufferedImage filter(BufferedImage bi) {
        bi = super.filter(bi);

        BufferedImage dstImg = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType());

        //Copy Image, blur
        setBlurStrength(40);
        BufferedImage tmp = blurFilter(bi);

        //Copy blur image
        BufferedImage tmp2 = applySaturation(tmp, -25);

        //Blending Mode: Overlay, 20%
        Graphics2D gtmp = tmp.createGraphics();
        gtmp.setComposite(BlendComposite.getInstance(BlendComposite.BlendingMode.OVERLAY, 0.2f));
        gtmp.drawImage(tmp2, 0, 0, bi.getWidth(), bi.getHeight(), null);


        //Blending Mode: Screen, 75%
        Graphics2D gdst = dstImg.createGraphics();
        gdst.drawImage(bi, 0, 0, null);
        gdst.setComposite(BlendComposite.getInstance(BlendComposite.BlendingMode.SCREEN, 0.75f));
        gdst.drawImage(tmp, 0, 0, bi.getWidth(), bi.getHeight(), null);

        return dstImg;
    }

}
